package com.huike.web.controller.clues;

import com.huike.clues.domain.TbClueTrackRecord;
import com.huike.clues.domain.vo.ClueTrackRecordVo;
import com.huike.clues.service.ClueService;
import com.huike.common.core.domain.AjaxResult;
import com.huike.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author STJ12138
 * @version 1.0
 * @description: TODO
 * @date 2023/7/12 11:16
 */
@RestController
@RequestMapping("/clues/record")
@Api(tags = "线索跟进记录管理相关接口")
@Slf4j
public class ClueController {
    @Resource
    private ClueService clueService;

    @GetMapping("/list")
    @ApiOperation("查询线索跟进记录列表")
    public TableDataInfo<List<TbClueTrackRecord>> list(Long clueId){
        List<TbClueTrackRecord> list = clueService.list(clueId);
        TableDataInfo<List<TbClueTrackRecord>> listTableDataInfo = new TableDataInfo<>();
        listTableDataInfo.setRows(list);
        return listTableDataInfo;
    }

    @GetMapping("/{id}")
    @ApiOperation("获取线索跟进记录详细信息")
    public AjaxResult<TbClueTrackRecord> getById(@PathVariable Long id){
        TbClueTrackRecord tbClueTrackRecord = clueService.getById(id);
        return AjaxResult.success(tbClueTrackRecord);
    }

    @PostMapping
    @ApiOperation("新增线索跟进记录")
    public AjaxResult<Long> save(@RequestBody ClueTrackRecordVo clueTrackRecordVo){
        Long id = clueService.add(clueTrackRecordVo);
        return AjaxResult.success(id);
    }
}
